cmake_minimum_required(VERSION 2.8.3)
project(demo)

if(${CMAKE_BUILD_TYPE} MATCHES  "Release")
  #set(CMAKE_BUILD_TYPE "Release") 
  set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -std=c++11 -Wall")
  message(STATUS "Mode: Release")
  message(STATUS "optional:-std=c++11 -Wall")
else()
  set(CMAKE_BUILD_TYPE "Debug") 
  set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -std=c++11 -Wall -Wextra -Wpedantic -g2 -ggdb")
  message(STATUS "Mode: Debug")
  message(STATUS "optional:-std=c++11 -Wall -Wextra -Wpedantic -g2 -ggdb")
endif()

###########
## Build ##
###########

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
  ${CMAKE_CURRENT_SOURCE_DIR}/include
)

set(JSONCPP_SRC ${CMAKE_CURRENT_SOURCE_DIR}/src/jsoncpp.cpp)

set(EXAMPLE_SRC_1 ${CMAKE_CURRENT_SOURCE_DIR}/src/readFromStream/readFromStream.cpp)

set(EXAMPLE_SRC_2 ${CMAKE_CURRENT_SOURCE_DIR}/src/readFromString/readFromString.cpp)

set(EXAMPLE_SRC_3 ${CMAKE_CURRENT_SOURCE_DIR}/src/streamWrite/streamWrite.cpp)

set(EXAMPLE_SRC_4 ${CMAKE_CURRENT_SOURCE_DIR}/src/stringWrite/stringWrite.cpp)

add_executable( readFromStream
  ${JSONCPP_SRC}
  ${EXAMPLE_SRC_1}
)

add_executable( readFromString
  ${JSONCPP_SRC}
  ${EXAMPLE_SRC_2}
)

add_executable( streamWrite
  ${JSONCPP_SRC}
  ${EXAMPLE_SRC_3}
)

add_executable( stringWrite
  ${JSONCPP_SRC}
  ${EXAMPLE_SRC_4}
)

#file(GLOB  LDLIDAR_DRI ${CMAKE_CURRENT_SOURCE_DIR}/ldlidar_driver/src/*.cpp)

#add_executable(
#  ${PROJECT_NAME}_node 
#  ${CMAKE_CURRENT_SOURCE_DIR}/src/linux_demo/demo.cpp
#)

#add_library(ldlidar_driver_static STATIC 
#  ${LDLIDAR_DRI} 
#)

#add_library(ldlidar_driver_shared SHARED 
#  ${LDLIDAR_DRI} 
#)

# rename library name
#set_target_properties (ldlidar_driver_static PROPERTIES OUTPUT_NAME "ldlidar_driver")
#set_target_properties (ldlidar_driver_shared PROPERTIES OUTPUT_NAME "ldlidar_driver")

# binary file link to library
#target_link_libraries(${PROJECT_NAME}_node ldlidar_driver_static pthread)

###########
## Install ##
###########

#INSTALL(TARGETS ldlidar_driver_static ldlidar_driver_shared
#  ARCHIVE DESTINATION lib/ldlidar_driver
#  LIBRARY DESTINATION share/ldlidar_driver
#)

#INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/ldlidar_driver/include
#  DESTINATION include/ldlidar_driver
#)
